package UntilTest;

import com.CampusLife.until.DataTime;
import org.junit.Test;

import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Time {
    @Test
    public void test(){
        DataTime dataTime = new DataTime();
      String time=  dataTime.CNtime();
      System.out.println(time);
    }
    @Test
    public void test1(){
        DataTime dataTime = new DataTime();
        String time=  dataTime.gettime();
        System.out.println(time);
    }

    @Test
    public void test2() {
        String str = "20200608192636";

        try {

            int a = Integer.parseInt(str);
            System.out.println(a);

        } catch (NumberFormatException e) {

            e.printStackTrace();

        }
    }
    @Test
    public  void test3(){
        //获得一个时间格式的字符串
        String dateStr = "2020-06-08 17:09:33";
        //获得SimpleDateFormat类，我们转换为yyyy-MM-dd的时间格式
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            //使用SimpleDateFormat的parse()方法生成Date
            Date date = sf.parse(dateStr);
            //打印Date
            System.out.println(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
}
